<%@ page contentType="text/html;charset=utf-8"%>
<%@page import="com.cs.beneficios.common.ConnectionFactory,com.cs.beneficios.business.entity.AuditoriaDAO,java.sql.Connection,java.sql.ResultSet,java.sql.SQLException"%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Usuario Modificador</title>
    
    <script language="javascript">
       
       function fAceptar(){
        document.form.submit();
        }
        
        function fbuscar(){
        document.form.submit();
        }
        
       function fDesvincular(){
          opener.document.frmauditoria.codusumodificador.value = "" ;
          opener.document.frmauditoria.usumodificador.value = "";
          window.close();      
        }
        
        function setValues(Codigo, Nombre)
        {
          opener.document.frmauditoria.codusumodificador.value = Codigo ;
          opener.document.frmauditoria.usumodificador.value = Nombre;
          window.close();                 
         }
         
    </script>   
  </head>
  <body>
  <link href="<%= request.getContextPath() + "/css/bloques.css" %>" rel="stylesheet" type="text/css">
  <P>&nbsp;</P>
    <P align="center"></P>
    <P align="center" class="titulosenblanco">USUARIO MODIFICADOR</P>
     <form name="frmCreateUser" method="post" action="usuarioModificador.jsp">
    <table cellspacing="2" cellpadding="3" border="0" width="60%" align="center">
      <tr>
        <td width="25%" height="8" class="celdatabla">
          <STRONG>Cedula</STRONG>
        </td>
        <td width="75%" height="8" colspan="2">
          <input type="text" class="form" name="cedula" value="" maxlength="10" size="10"/>
        </td>
      </tr>
      <tr>
        <td width="25%" class="celdatabla">
          <STRONG>Descripcion</STRONG>
        </td>
        <td width="75%" colspan="2">
          <input type="text" class="form"  name="usuario" value="" maxlength="20" size="20"/>
        </td>
      </tr>
      <tr>
        <td width="25%" height="8"></td>
        <td width="75%" height="8" colspan="2"></td>
      </tr> 
      
      <tr>
        <td width="25%" height="8"></td>
        <td width="75%" height="8" colspan="2"></td>
      </tr>
      <tr>
        <td width="25%">
        </td>
        <td width="16%">
          <input type="submit" value="Buscar" language="javascript" onclick="fbuscar"/>
        </td>
        <td width="59%">
          <input type="button" value="Desvincular" language="javascript" onclick="fDesvincular()"/>
        </td>

      </tr>
    </table>
    <P></P>
    <P>
      <% 
    //ConnectionFactory cf = new ConnectionFactory("beneficios","beneficios");
	ConnectionFactory cf = new ConnectionFactory();
    AuditoriaDAO objAuditDAO = new AuditoriaDAO(cf);
    
    String primeraVez = null;

    primeraVez = (String)session.getAttribute("primeraVez"); 
    
    ResultSet rs = null;
      if(primeraVez != null){
          try{
             rs = objAuditDAO.getUsers(request.getParameter("cedula"),request.getParameter("usuario"));   
             }catch(Exception e){
              e.printStackTrace();
            }
        }else{
          session.setAttribute("primeraVez","false"); 
        }
     %>
    </P>
    <DIV align="center">
 <% if(primeraVez != null){
      if(rs != null){
        try{%>
         <table style="form" cellspacing="3" cellpadding="2" border="0" width="60%" align="center">
          <tr>
            <td width="10%" class="headerTable">CODIGO</td>
            <td width="65%" class="headerTable">NOMBRE</td>
            <td width="65%" class="headerTable">DESCRIPCION</td>
            <td width="15%" class="headerTable">SELECCIONAR</td>
          </tr>
         <%while(rs.next()){  %>
                <tr>
                  <td width="10%" class="form"><%=rs.getString("codigo")%></td>
                  <td width="65%" class="form"><%=rs.getString("nombre")%></td>
                  <td width="65%" class="form"><%=rs.getString("descripcion")%></td>
                  <td width="15%" class="form"><input type="radio"  name="seleccionar" onclick='setValues(Codigo="<%=rs.getString("codigo")%>",Nombre="<%=rs.getString("nombre")%>")'/></td>
                </tr>
            <%}%>
          </table>
      <%}catch(SQLException e){
            e.printStackTrace();
          }
        }else{ %>
          <div align="center" class="celdatabla"> No se encontraron registros...</div>  
          <%}
          }else{
       session.setAttribute("primeraVez","false"); 
       }   
          %>        
         </DIV>
      </form>
    <P align="center">&nbsp;</P>
    <% cf.closeConnection(objAuditDAO.getConn());%>
  </body>
</html>